import store from '@/store/index'
import { getChannels } from '@/views/operate/saleCRM/api'
export let list = []
getChannels({ areaId: 'f56430d1ff8d4c16be2baa0e6ea42574' }).then((res) => {
  clueAddFrom[0].option = res
  expFrom[0].option = res
  list = res
})

export const rankpColor = ['#ff574a', '#ff8400', '#7b7889']
export const zhwysStatusColor = [
  '#ff574a',
  '#ff8400',
  '#7ecb33',
  '#5f9ff4',
  '#777585'
]

// 线索级别
export const rankp = [
  {
    value: '0',
    label: 'A-重点客户',
    color: '"#ff574a"'
  },
  {
    value: '1',
    label: 'B-普通客户',
    color: '#ff8400'
  },
  {
    value: '2',
    label: 'C-非优先客户',
    color: '#7b7889'
  }
]
// 线索状态
export const zhwysStatus = [
  {
    value: '0',
    label: '新线索'
  },
  {
    value: '1',
    label: '跟进中'
  },
  {
    value: '2',
    label: '已缴订金'
  },
  {
    value: '3',
    label: '已转化'
  },
  {
    value: '4',
    label: '已放弃'
  }
]

export const tableTitle = [
  // 字段已对
  {
    name: '家长姓名',
    key: 'name'
  },
  {
    name: '联系方式',
    key: 'mobile'
  },
  {
    name: '宝宝姓名',
    key: 'childName'
  },
  {
    name: '出生年月',
    key: 'birthday',
    times: true
  },
  {
    name: '宝宝月龄',
    key: 'monthsDiff'
  },
  {
    name: '家庭住址',
    key: 'homeAddress'
  },
  {
    name: '线索级别',
    key: 'rankp',
    slot: true,
    option: rankpColor
  },
  {
    name: '线索状态',
    key: 'zhwysStatus',
    slot: true,
    option: zhwysStatusColor
  },
  {
    name: '最近跟进时间',
    key: 'lastFollowTime',
    times: true
  },
  {
    name: '下次跟进时间', // nextTime
    key: 'nextTime',
    times: true
  },
  {
    name: '负责人',
    key: 'staffName'
  }
]

// 预约试托
export const experimentalPalletTableTitle = [
  // 字段没对完
  {
    name: '家长姓名',
    key: 'name'
  },
  {
    name: '联系方式',
    key: 'mobile'
  },
  {
    name: '宝宝姓名',
    key: 'childName'
  },
  {
    name: '宝宝月龄',
    key: 'monthsDiff'
  },
  {
    name: '预约试托时间',
    key: 'visitTime'
  },
  {
    name: '试托状态',
    key: 'status',
    data: {
      1: '已试托',
      2: '未试托'
    }
  },
  {
    name: '下次跟进时间',
    key: 'nextTime'
  },
  {
    name: '备注',
    key: 'remark'
  },
  {
    name: '负责人',
    key: 'staffName'
  }
]
// 预约到访
export const subscribeVisitTableTile = [
  // 字段没对完
  {
    name: '家长姓名',
    key: 'name'
  },
  {
    name: '联系方式',
    key: 'mobile'
  },
  {
    name: '宝宝姓名',
    key: 'childName'
  },
  {
    name: '宝宝月龄',
    key: 'monthsDiff'
  },
  {
    name: '预约到访时间',
    key: 'visitTime'
  },
  {
    name: '备注',
    key: 'remark'
  },
  {
    name: '下次跟进时间',
    key: 'nextTime'
  },
  {
    name: '到访状态',
    key: 'status',
    data: {
      1: '已到访',
      2: '未到访'
    }
  },
  {
    name: '负责人',
    key: 'staffName'
  }
]

export const rules = {
  channelId: [{ required: true, message: '请选择线索来源', trigger: 'change' }],
  rankp: [{ required: true, message: '请选择线索级别', trigger: 'change' }],
  zhwysStatus: [
    { required: true, message: '请选择线索状态', trigger: 'change' }
  ],
  name: [{ required: true, message: '请输入家长姓名', trigger: 'blur' }],
  mobile: [
    { required: true, message: '请输入联系方式', trigger: 'blur' },
    {
      pattern: /^1[3456789]\d{9}$/,
      message: '手机号码格式不正确',
      trigger: 'blur'
    }
  ],
  childName: [{ required: true, message: '请输入宝贝姓名', trigger: 'blur' }],
  visitTime: [
    { required: true, message: '请选择预约试托时间', trigger: 'blur' }
  ]
}

export const rulesD = {
  channelId: [{ required: true, message: '请选择线索来源', trigger: 'change' }],
  rankp: [{ required: true, message: '请选择线索级别', trigger: 'change' }],
  zhwysStatus: [
    { required: true, message: '请选择线索状态', trigger: 'change' }
  ],
  name: [{ required: true, message: '请输入家长姓名', trigger: 'blur' }],
  mobile: [
    { required: true, message: '请输入联系方式', trigger: 'blur' },
    {
      pattern: /^1[3456789]\d{9}$/,
      message: '手机号码格式不正确',
      trigger: 'blur'
    }
  ],
  childName: [{ required: true, message: '请输入宝贝姓名', trigger: 'blur' }],
  visitTime: [
    { required: true, message: '请选择预约到访时间', trigger: 'blur' }
  ]
}

export const addRules = {
  rankp: [{ required: true, message: '请选择线索级别', trigger: 'change' }],
  channel: [{ required: true, message: '请选择跟进方式', trigger: 'change' }],
  nextTime: [
    { required: true, message: '请选择下次跟进时间', trigger: 'change' }
  ],
  content: [{ required: true, message: '请输入跟进详情', trigger: 'blur' }]
}

// 线索管理新增
export const clueAddFrom = [
  {
    index: 1,
    type: 'select',
    label: '线索来源',
    value: 'channelId',
    option: [],
    placeholder: '请选择线索来源'
  },
  {
    index: 2,
    type: 'select',
    label: '线索级别',
    value: 'rankp',
    option: rankp,
    placeholder: '请选择线索级别'
  },
  {
    index: 3,
    type: 'select',
    label: '线索状态',
    value: 'zhwysStatus',
    option: zhwysStatus,
    placeholder: '请选择线索状态'
  },
  {
    index: 4,
    type: 'input',
    label: '家长姓名',
    value: 'name',
    placeholder: '请输入家长姓名'
  },
  {
    index: 5,
    type: 'input',
    label: '联系方式',
    value: 'mobile',
    placeholder: '请输入联系方式'
  },
  {
    index: 6,
    type: 'distpicker',
    label: '家庭住址',
    value: 'homeAddress',
    options: [],
    placeholder: '省/市/区'
  },
  {
    index: 7,
    type: 'input',
    label: '',
    value: 'address',
    placeholder: '请输入具体地址'
  },
  {
    index: 8,
    type: 'select',
    label: '关系',
    value: 'relationship',
    option: store.getters.dict.relationships,
    placeholder: '请选择'
  },
  {
    index: 9,
    type: 'input',
    label: '宝贝姓名',
    value: 'childName',
    placeholder: '请输入宝贝姓名'
  },
  {
    index: 10,
    type: 'select',
    label: '宝贝性别',
    value: 'gender',
    option: store.getters.dict.sex,
    placeholder: '请选择'
  },
  {
    index: 11,
    type: 'picker',
    label: '出生年月',
    value: 'birthday',
    placeholder: '选择日期',
    valueFormat: 'yyyy-MM-dd'
  },
  {
    index: 13,
    type: 'textarea',
    label: '备注',
    value: 'remark',
    placeholder: ''
  }
]

export const infoFrom = [
  {
    type: 'select',
    label: '线索级别',
    value: 'rankp',
    option: rankp,
    placeholder: '请选择线索级别'
  },
  {
    type: 'select',
    label: '跟进方式',
    value: 'channel',
    option: store.getters.dict.clueFollowTypes,
    placeholder: '请选择跟进方式'
  },
  {
    type: 'picker',
    label: '下次跟进时间',
    value: 'nextTime',
    placeholder: '选择日期',
    valueFormat: 'yyyy-MM-dd'
  },
  {
    type: 'radio',
    label: '是否预约到访',
    value: 'isVisit',
    option: [
      {
        label: '是',
        value: 1
      },
      {
        label: '否',
        value: 0
      }
    ]
  },
  {
    type: 'picker',
    label: '',
    value: 'visitTime',
    placeholder: '请选择到访时间',
    valueFormat: 'yyyy-MM-dd'
  },
  {
    type: 'textarea',
    label: '',
    value: 'remark',
    placeholder: '到访备注，如无可不填写',
    autosize: { minRows: 4, maxRows: 5 }
  },
  {
    type: 'radio',
    label: '是否预约试托',
    value: 'isPallet',
    option: [
      {
        label: '是',
        value: 1
      },
      {
        label: '否',
        value: 0
      }
    ]
  },
  {
    type: 'picker',
    label: '',
    value: 'palletTime',
    placeholder: '请选择试托时间',
    valueFormat: 'yyyy-MM-dd'
  },
  {
    type: 'textarea',
    label: '跟进详情',
    value: 'content',
    placeholder: '跟进详情',
    autosize: { minRows: 4, maxRows: 5 }
  },
  {
    type: 'upload',
    label: '图片',
    value: 'imgUrl', // 无对接
    listType: true,
    action: ''
  }
]

export const subFrom = [
  {
    type: 'input',
    label: '家长姓名',
    value: 'name',
    placeholder: '请输入家长姓名'
  },
  {
    type: 'input',
    label: '联系方式',
    value: 'mobile',
    placeholder: '请输入联系方式'
  },
  {
    type: 'distpicker',
    label: '家庭住址',
    value: 'provinceCityArea',
    options: [],
    placeholder: '省/市/区'
  },
  {
    type: 'input',
    label: '',
    value: 'address',
    placeholder: '请输入具体地址'
  },
  {
    type: 'select',
    label: '关系',
    value: 'relationship',
    option: store.getters.dict.relationships,
    placeholder: '请选择'
  },
  {
    type: 'input',
    label: '宝宝姓名',
    value: 'childName',
    placeholder: '请输入宝宝姓名'
  },
  {
    type: 'picker',
    label: '出生年月',
    value: 'birthday',
    placeholder: '选择日期',
    valueFormat: 'yyyy-MM-dd'
  },
  {
    type: 'select',
    label: '宝贝性别',
    value: 'gender',
    option: store.getters.dict.sex,
    placeholder: '请选择'
  },
  {
    type: 'textarea',
    label: '备注',
    value: 'remark',
    placeholder: '',
    autosize: { minRows: 3, maxRows: 4 }
  }
]

export const expFrom = [
  {
    type: 'select',
    label: '线索来源',
    value: 'channelId',
    option: [],
    placeholder: '请选择'
  },
  {
    type: 'select',
    label: '线索级别',
    value: 'rankp',
    option: rankp,
    placeholder: '请选择线索级别'
  },
  {
    type: 'select',
    label: '线索状态',
    value: 'zhwysStatus',
    option: zhwysStatus,
    placeholder: '请选择线索状态'
  },
  {
    type: 'input',
    label: '家长姓名',
    value: 'name',
    placeholder: '请输入家长姓名'
  }
]

export const addSubscribeVisit = [
  {
    type: 'picker',
    label: '预约到访时间',
    value: 'visitTime',
    placeholder: '选择日期',
    valueFormat: 'yyyy-MM-dd' // 无对接
  },
  {
    type: 'textarea',
    label: '到访详情',
    value: 'content',
    placeholder: '请输入',
    autosize: { minRows: 3, maxRows: 7 } // 无对接
  },
  {
    type: 'upload',
    label: '图片',
    value: 'imgUrl', // 无对接
    listType: true,
    action: ''
  },
  {
    type: 'radio',
    label: '是否预约试托',
    value: 'isPallet', // 无对接
    option: [
      {
        label: '是',
        value: 1
      },
      {
        label: '否',
        value: 0
      }
    ]
  },
  {
    type: 'picker',
    label: '',
    value: 'palletTime',
    placeholder: '请选择试托时间',
    valueFormat: 'yyyy-MM-dd',
    pickerOptions: {
      disabledDate (date) {
        return date.getTime() < Date.now() - 8.64e7 // 只能选择今天及今天之后的日期，如果没有后面的-8.64e7就是今天也不能选
      }
    }
  },
  {
    type: 'picker',
    label: '下次跟进时间',
    value: 'nextTime',
    placeholder: '选择日期',
    valueFormat: 'yyyy-MM-dd',
    pickerOptions: {
      disabledDate (date) {
        return date.getTime() < Date.now() - 8.64e7 // 只能选择今天及今天之后的日期，如果没有后面的-8.64e7就是今天也不能选
      }
    }
  }
]

export const experimentalData = [
  {
    type: 'picker',
    label: '预约试托时间',
    value: 'palletTime',
    placeholder: '选择日期',
    valueFormat: 'yyyy-MM-dd'
  },
  {
    type: 'textarea',
    label: '试托详情',
    value: 'content',
    placeholder: '',
    autosize: { minRows: 3, maxRows: 4 }
  },
  {
    type: 'upload',
    label: '图片',
    listType: true,
    value: 'imgUrl',
    action: ''
  },
  {
    type: 'picker',
    label: '下次跟进时间',
    value: 'nextTime',
    placeholder: '选择日期',
    valueFormat: 'yyyy-MM-dd',
    pickerOptions: {
      disabledDate (date) {
        return date.getTime() < Date.now() - 8.64e7 // 只能选择今天及今天之后的日期，如果没有后面的-8.64e7就是今天也不能选
      }
    }
  }
]

export const addSubscribeVisitRules = {
  // 无对接
  content: [{ required: true, message: '请输入到访详情', trigger: 'blur' }],
  nextTime: [
    { required: true, message: '请选择下次跟进时间', trigger: 'change' }
  ]
}

export const subtext = [
  {
    name: '家长姓名',
    key: 'name'
  },
  {
    name: '联系方式',
    key: 'mobile'
  },
  {
    name: '关系',
    key: 'relationship'
  },
  {
    name: '宝宝姓名',
    key: 'childName'
  },
  {
    name: '宝宝性别',
    key: 'gender',
    slot: true,
    option: store.getters.dict.sex
  },
  {
    name: '宝宝月龄',
    key: 'monthsDiff'
  },
  {
    name: '出生年月',
    key: 'birthday'
  },
  {
    name: '家庭住址',
    key: 'homeAddress'
  }
]
